<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">经营查询</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <!-- 委托运营 -->
                <el-form ref="wtjyform" :model="wtjyform" label-width="80px" :inline="true" size="mini">
                    <el-form-item label="房屋地址:">
                        <div style="width:190px">
                            <el-input v-model="wtjyform.fwdz" placeholder="请输入房屋地址"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="档案编号:">
                        <div style="width:190px">
                            <el-input v-model="wtjyform.dabh" placeholder="请输入档案编号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="产权单位:">
                        <div style="width:190px">
                            <el-input v-model="wtjyform.cqdw" placeholder="请输入产权单位"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="承租人:">
                        <div style="width:190px">
                            <el-input v-model="wtjyform.czr" placeholder="请输入承租人"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="产别:">
                        <div style="width:190px">
                            <el-select v-model="wtjyform.cb" placeholder="请选择产别" clearable>
                                <el-option v-for="item in cblist" :key="item.code" :label="item.name" :value="item.code">
                                </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search"
                            class="searchcolor">查询</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <el-table :data="wtjytableData" style="width: 100%" :header-cell-style="tableHeaderColor"
                :row-style="tablerowColor" border>
                <el-table-column prop="qs" label="区属" align="center"> </el-table-column>
                <el-table-column prop="fwdz" label="房屋地址" align="center">
                    <template slot-scope="scope">
                        <span style="font-weight: 700;color: #409ee1;">
                            {{ scope.row.fwdz }}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column prop="cqdw" label="产权单位" align="center" width="220px"> </el-table-column>
                <el-table-column prop="cb" label="产别" align="center"> </el-table-column>
                <el-table-column prop="dabh" label="档案编号" align="center"> </el-table-column>
                <el-table-column prop="yzj" label="月租金" align="center"> </el-table-column>
                <el-table-column prop="jzmj" label="建筑面积" align="center"> </el-table-column>
                <el-table-column label="操作" width="160" align="center">
                    <template slot-scope="scope">
                        <router-link :to="{ name: 'projectdetail', params: { id: scope.row.id } }" v-if="scope.row.signid">
                            <el-button type="text" size="small">详情</el-button>
                        </router-link>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination background layout="total,prev, pager, next,jumper" :total="wtjytotal"
                    :current-page.sync="wtjycurrent" :page-size="pageSize"
                    @current-change="handleCurrentChange">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { projectdelete, wtdwsignlist } from '@/api/index';
import valueList from '@/components/common/valueList.vue'
export default {
    name: 'dalistone',
    data() {
        return {
            cblist: valueList.cblist,
            qslist: valueList.qslist,//区属
            cqdwlist: valueList.cqdwlist,//产权单位
            ztlist: valueList.ztlist,//状态
            total: 0,
            current: 1,
            wtjytotal: 0,
            wtjycurrent: 1,
            czjytotal: 0,
            czjycurrent: 1,
            pageSize: 10,
            wtjyform: {
                cb: '',
                cqdw: '',
                create_name: '',
                create_name_id: '',
                create_time: '',
                current: 1,
                czr: '',
                dabh: '',
                dqsj: '',//合同到期时间 ,
                fwdz: '',//地址 ,
                id: '',
                jzmj: '',//建筑面积 ,
                pageSize: 10,//每页数量 ,
                qs: '',//区属 ,
                signid: '',
                status_code: '1',
                type: this.$store.getters.type,//分类 1:房屋 2：楼栋 ,
                update_name: '',
                update_name_id: '',
                update_time: '',
                yzj: ''
            },
            wtjytableData: []
        };
    },
    components: {},
    computed: {
        // 判断变色
        getcolorred(zt) {
            console.log(zt);
            return (zt) => {
                if (zt == "已出租") {
                    return { color: "#19BE6B", fontWeight: 700 };
                } else {
                    return { color: "#409ee1", fontWeight: 700 };
                }
            };
        },
    },
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background-color: #f7f7f7;color:black;height: 54px;font-weight: 500;font-size:14px;font-variant:tabular-nums'
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;'
        },
        // 换页
        handleCurrentChange() {

            this.wtjycurrent = val;
            this.wtjyform.current = val;
            this.wtdwsignlist(this.wtjyform);

        },
        // 搜索
        onSearch() {
            this.wtjycurrent = 1;
            this.wtjyform.current = 1;
            this.wtdwsignlist(this.wtjyform);

        },
        // 删除
        deleteClick(e) {
            console.log(e);
            this.$confirm('确定删除此条信息吗？')
                .then(() => {
                    let data = { id: e.id };
                    projectdelete(data).then((res) => {
                        if (res.code == 200) {
                            this.wtdwsignlist(this.wtjyform);
                            this.$message.success('删除成功');
                        }
                    });
                })
                .catch(() => {
                    this.$message.success('删除取消');
                });
        },
        // 委托运营
        wtdwsignlist(data) {
            wtdwsignlist(data).then((res) => {
                // console.log('res',res)
                if (res.code == 200) {
                    this.wtjytableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.wtjytableData = [];
                    this.total = 0;
                }
            });
        },
    },
    mounted() {
        this.wtdwsignlist(this.wtjyform)
    }
};
</script>

<style scoped>
.container {
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
